import axios from "axios";
import {store} from "../redux/store";

axios.defaults.baseURL="http://localhost:5000"

//显示loading
axios.interceptors.request.use(//请求发出去前的拦截
    function (config){
        store.dispatch({
            type:"change_loadding",
            payload:true
        })
        return config;
    },function (error){
        return Promise.reject(error);
    }
)
//隐藏loading
axios.interceptors.response.use(//响应回来时的拦截
    function (config){
        store.dispatch({
            type:"change_loadding",
            payload:false
        })
        return config;
    },function (error){
        return Promise.reject(error);
    }
)